function xmkj(e,type){
    var runId = workForm.option.runId
    var prcsId = workForm.option.prcsId
    if(type == 0){
        var data={};
    }else{
        var data = {runId:runId,prcsId:prcsId}
    }

    layer.open({
        type: 1,
        title:['预算项目', 'background-color:#2b7fe0;color:#fff;'],
        area: ['520px', '380px'],
        shadeClose: true, //点击遮罩关闭
        btn: [sure, cancel],
        content:'<span id="protionId">项目列表：</span>'+
        '<ul class="xmList">' +
        '</ul>',
        success:function(){
            $.ajax({
                url:'/budget/selAllBudgetFlow',
                dataType:'json',
                data:data,
                success:function(res){
                    var data=res.obj;
                    var str = "";
                    for(var i=0;i<data.length;i++){
                        var item = data[i];
                        var lineNo = data[i].lineNo.split(',').join('')
                        str += '<label><li class="lis" style="line-height: 25px;border-bottom:1px dashed #000"><input  class="ipt" type="radio" value="'+data[i].budgetId+'"  itemMon="'+data[i].itemMoney+'" mons="'+data[i].remainingAmount+'" user="'+data[i].itemManager+'" yuzhi="'+data[i].allAdvance+'"   mon="'+data[i].realRemainingAmount+'" num="'+lineNo+'" name="control"  nameId="'+data[i].budgetItemName
                            +'"><span style="padding-right:10px;" onmouseenter="biaoqian(this)" onmouseleave="shebiaoqian(this)">'+data[i].budgetItemName+'</span> <span style="padding-left:10px;float:right;margin-right:40px;">'+data[i].lineNo+'</span></li></label>'
                    }
                    $('.xmList').html(str)

                }
            })
        },
        yes:function(){

            var name = $('.ipt:checked').attr('nameId')
            var yuzhi = $('.ipt:checked').attr('yuzhi')
            var money = $('.ipt:checked').attr('mon');
            var num = $('.ipt:checked').attr('num');
            var value = $('.ipt:checked').attr('value');
            var itemMon = Number($('.ipt:checked').attr('itemMon'));
            var mon = Number($('.ipt:checked').attr('mon'));
            var user = $('.ipt:checked').attr('user');
            var mons = $('.ipt:checked').attr('mons');


            if(type == 0){
                $('#DATA_218').val(mons)
                $('input[name = "DATA_220"]').val(num)
                $('input[name = "DATA_211"]').val(name)
                $('input[name = "DATA_213"]').val(value)
            }else{
                e.parents('tr').find('td').eq(3).find('input').val(num)
                e.parents('tr').find('td').eq(4).find('input').val(name)
                e.parents('tr').find('td').eq(5).find('input').val(user)
                e.parents('tr').find('td').eq(6).find('input').val(itemMon)
                e.parents('tr').find('td').eq(7).find('input').val((itemMon-mon).toFixed(2))
                e.parents('tr').find('td').eq(9).text(parseFloat(mons))
                e.parents('tr').find('td').eq(8).find('input').val(yuzhi)
                e.parents('tr').find('td').eq(11).find('input').val(value)
            }
            /*$('input[name = "DATA_218"]').val(money)*/

            layer.closeAll()
        }

    });
}
function  biaoqian(_this) {
    _this.style.color = 'rgb(43, 127, 224)';

}
function  shebiaoqian(_this) {
    _this.style.color = '';

}
function ckrz(e){
    layer.open({
        type: 1,
        title:['查看日志', 'background-color:#2b7fe0;color:#fff;'],
        area: ['650px', '380px'],
        shadeClose: true, //点击遮罩关闭
        btn: ['关闭'],
        content:'<div style="width:100%;height:100%;overflow: auto"><table id="uploadTable" style="width: 100%;margin: 0 auto;">' +
        '                    <thead>' +
        '                       <tr style="background:none">' +
        '                         <th style="width: 80px;">步骤号</th>' +
        '                          <th>经办人</th>' +
        '                          <th>时间</th>' +
        '                           <th>项目名</th>' +
        '                           <th>金额</th>' +
        '                           <th>状态</th>' +
        '                    </tr>' +
        '                       </thead>' +
        '                      <tbody class="list"></tbody>' +
        '                 </table></div>',
        success:function(){
            $.ajax({
                url:'/budgetProLog/saveLog',
                dataType:'json',
                data:{runId:$.GetRequest().runId},
                success:function(res){
                    var data = res.data;
                    var str = ''
                    for(var i=0;i<data.length;i++){
                        str += '                <tr style="background:none">' +
                            '                            <td style="width: 80px;">第'+data[i].prcsId+'步：'+data[i].prcsName+'</td>' +
                            '                            <td>'+data[i].userName+'</td>' +
                            '                           <td>'+data[i].logTime+'</td>' +
                            '                          <td>'+data[i].itemName+'</td>' +
                            '                            <td>'+data[i].money+'</td>' +
                            '                           <td>'+function(){
                                if(data[i].logType == '1'){
                                    return '加'
                                }else if(data[i].logType == '2'){
                                    return '减'
                                }else{
                                    return '无'
                                }
                            }()+'</td>' +

                            '                       </tr>'
                    }
                    $('#uploadTable .list').html(str)

                }
            })
        },
    });
}
/*function xmxq(e){
    layer.open({
        type: 1,
        title:['预算项目', 'background-color:#2b7fe0;color:#fff;'],
        area: ['945px', '420px'],
        shadeClose: true, //点击遮罩关闭
        content:'<div id="listBox"><span id="protionId">项目详情列表：</span>'+
        '<table class="xmList" border="1">' +
            '<thead>' +
            '<th>上级项目</th>'+
            '<th>项目名称</th>'+
            '<th>项目金额</th>'+
            '<th>所属部门</th>'+
        '</thead>'+
            '<tbody></tbody>'+
        '</table></div>',
        success:function(){
            $.ajax({
                url:'/budget/selAllBudget',
                dataType:'json',
                success:function(res){
                    var data=res.obj;
                    var str = "";
                    console.log(data)
                    for(var i=0;i<data.length;i++){
                        str += '<tr>' +
                            '<td>'+undefindData(data[i].priveItem)+'</td>'+
                            '<td>'+data[i].budgetItemName+'</td>'+
                            '<td>'+data[i].itemMoney+'</td>'+
                            '<td>'+undefindData(data[i].department)+'</td>'+
                            '</tr>'
                    }
                    $('#listBox tbody').html(str)

                }
            })
        }
    });
}*/
function xmxq(e){
    if(e.css('display') == 'inline-block'){
        var  budgetId = $('#DATA_213').val()
    } else{
        var  budgetId = e.parent().parent().find('td').eq(11).find('input').val()
    }

    $.popWindow("/budget/newjournal1?budgetId="+budgetId,"","","",'1000');
}
function undefindData(data) {
    if(data == undefined){
        return ' ';
    }else{
        return data;
    }
}
function onKeyUp(){
    var num1 = $('#DATA_171').val();
    var num2 = $('#DATA_218').val();
    if(parseInt(num1) > parseInt(num2)){
        alert('输入的款额超出可用金额！请重新输入！');
        num1 = '';
    }
}


//二小专用js
//判断列表的宽度，二小列表数据多，增加宽度
// function width(){
//     if(((flowId == 170 && dataId == 'DATA_225') || (flowId == 170 && dataId == 'DATA_227'))||((flowId == 324 && dataId == 'DATA_225') || (flowId == 324 && dataId == 'DATA_227'))){  //如果是支票
//         tableWidth = tableWidth+150
//     }
// }